home *** CD-ROM | disk | FTP | other *** search
- Path: walt.tsc.com!not-for-mail
- From: billr@elmer.tsc.com (Bill Roberts)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: x ^= y ^= x ^= y;
- Date: 29 Feb 1996 14:03:34 -0500
- Organization: Technology Service Corporation
- Sender: Bill Roberts
- Message-ID: <4h4ta6$ivf@elmer.tsc.com>
- References: <4glcf7$eou@wn1.sci.kun.nl> <972.6628T1080T1212@cs.ruu.nl>
- NNTP-Posting-Host: elmer.tsc.com
-
- In article <972.6628T1080T1212@cs.ruu.nl>,
- Wessel Dankers <wsldanke@cs.ruu.nl> wrote:
- !
- !Olaf Seibert <rhialto@mbfys.kun.nl> wrote:
- !>> x ^= y ^= x ^= y;
- !
- <snip statement that you can't do this and why>
- !
- !It has been tested and used. Remember that the ^= is right associative:
- !read it as:
- !
- !x ^= (y ^= (x ^= y));
- !
- !The result-value of (x ^= y) is equal to the new value of x, mutatis mutandis
- !for (y ^= x).
- !
- The result of the evaluations is done in the order you have shown.
- The storage does not have to be done in the order shown. Therefore, x
- could end up with either of the value of the first xor or the second
- xor. The same for y. It may work on the compiler you are using. It
- may not work on another equally correct compiler. This case is
- specifically stated as producing undefined results in the ANSI C
- standard. The comp.lang.c FAQ's specifically discuss this problem and
- why it is undefined.
-